package test.day01;

import java.util.Scanner;

public class RandomDemo {
    public static void main(String[] args) {
        int a = (int) (Math.random() * 100 + 1);//随机数Math.random()范围是0～1（不包含1）；
        // 规律：1～100则是1～101；乘101-1，加1；
        Scanner scan = new Scanner(System.in);
        int b = scan.nextInt();

        int i = 1;//定义下限
        int j = 100;//定义上限

        while (a != b) {
            if (b > a) {
                System.out.println("猜大了" + i + "~" + b);
                j = b;//猜大了，说明上限最大为此
            } else {
                System.out.println("猜小了" + b + "~" + j);
                i = b;//猜小了，说明下限最小为此
            }
            b = scan.nextInt();
        }
        System.out.println("猜对了" + b);

    }
}
